package org.jeecg.modules.fk.utils;

import java.util.Set;

/**
 * @author chensherun on 2023/1/4.
 * @version 1.0
 */
public class CheckRoleUtil {
    //超管
    private final static String SUPER_ADMIN = "superAdmin";
    //省行配置成员,所有功能权限
    private final static String SYS_PROVINCE_ADMIN = "sysProvinceAdmin";
    //省行领导
    private final static String PROVINCE_ADMIN = "provinceAdmin";
    //分行(支行)领导
    private final static String BRANCH_ADMIN = "branchAdmin";
    //网点领导
    private final static String OUTLETS_ADMIN = "outletsAdmin";
    //生产要素经办岗（普通员工）
    private final static String PERSON = "person";

    /**
     * 判断是否为superAdmin
     * @param roles
     * @return
     */
    public static boolean checkIsSuper(Set<String> roles) {
        if (roles == null || roles.isEmpty()) {
            return false;
        }
        return roles.contains(SUPER_ADMIN);
    }

    /**
     * 检查是否超级管理员
     * @param roles
     * @return
     */
    public static boolean checkIsSysAdmin(Set<String> roles) {
        if (roles == null || roles.isEmpty()) {
            return false;
        }
        return roles.contains(SUPER_ADMIN);
    }

    /**
     * 检查是否生产要素系统管理员 省行、分支行、网点领导
     * @param roles
     * @return
     */
    public static boolean checkIsDeptAdmin(Set<String> roles) {
        if (roles == null || roles.isEmpty()) {
            return false;
        }
        return roles.contains(SYS_PROVINCE_ADMIN)
                || roles.contains(PROVINCE_ADMIN)
                || roles.contains(BRANCH_ADMIN)
                || roles.contains(OUTLETS_ADMIN);
    }

    /**
     * 生产要素经办岗
     * @param roles
     * @return
     */
    public static boolean checkIsPerson(Set<String> roles) {
        if (roles == null || roles.isEmpty()) {
            return false;
        }
        return roles.contains(PERSON);
    }
}
